package cn.zhibang.yygh2.service.sms.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ConstantPropertiesUtils implements InitializingBean { //初始化类
    //读取application.yml中的aliyun.sms.regionId值，注入到regionId属性中
    @Value("${aliyun.sms.regionId}")
    private String regionId;
    //读取application.yml中的aliyun.sms.accessKeyId值，注入到accessKeyId属性中
    @Value("${aliyun.sms.accessKeyId}")
    private String accessKeyId;
    //读取application.yml中的aliyun.sms.accessKeySecret值，注入到accessKeySecret属性中
    @Value("${aliyun.sms.secret}")
    private String accessKeySecret;

    public static String REGION_Id;
    public static String ACCESS_KEY_ID;
    public static String SECRECT;

    //初始化时执行赋值
    @Override
    public void afterPropertiesSet() throws Exception {
        REGION_Id = regionId;
        ACCESS_KEY_ID = accessKeyId;
        SECRECT = accessKeySecret;
    }
}
